package com.fap.search.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fap.search.executor.DataRow;
import com.fap.search.executor.IExecutor;
import com.fap.search.meta.IFunctionMeta;
import com.fap.search.parameter.IParameter;
import com.fap.search.service.ISearchMetaService;
import com.fap.search.service.ISearchService;

@Component
public class SearchService implements ISearchService {

	@Autowired
	private ISearchMetaService _meta;

	public List<DataRow> invoke(String id, IParameter[] parameters)
			throws Exception {
		IFunctionMeta funcMeta = _meta.getFunctionMeta(id);
		IExecutor exec = funcMeta.buildExecutor();
		return exec.run(parameters);
	}
	
}
